#include <my_head.h>
int main(int argc, char const *argv[])
{
    pid_t pid=0;
    if(-1==(pid=fork())){
        ERR_LOG("fork error");
    }else if(0<pid){
        exit(EXIT_SUCCESS);
    }esle(0==pid){
        if(-1==setsid()){
            ERR_LOG("setsid error");
        }
        if(-1==chadir("/"))
            ERR_LOG("chadir error");
        umask(0066);
        for(i=3;i<1024;i++){
            close(i);
        }
        int fd=fopen("nihao.log",O_WRONLY|O_CREAT|O_TRUNC,0664);
        if(-1==fd){
            ERR_LOG("open error");
        dup2(fd,0);
        dup2(fd,1);
        dup2(fd,2);
        int i=0;
        while(1){
            printf("hellwo\n",++i);
            fflush(stdout);
            sleep(1);
        }
        close(fd);
        }
    }
    return 0;
}
